Raspberry Pi Coding For Novices by Dvorjak Keith

Raspberry Pi Coding For Novices by Dvorjak Keith

Author:Dvorjak, Keith [Dvorjak, Keith]
Language: eng
Format: azw3
Published: 2019-04-19T16:00:00+00:00


Exercise: Slice out the first three characters of the string action,

>>> action[:27]

'I am learning Raspberry Pi '

>>>

>>> action[4:8]

' lea'

>>>

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Lists

If you understand strings, you will easily understand Lists. A “list” in programming is a list of elements. See the example given below, showing a list of numbers.

Creating a List

Exercise: Define a List and print its value

>>> gifts = ['toys', 'clothes', 'jewellery', 'flower vase', 'bed sheets']

>>> gifts

['toys', 'clothes', 'jewellery', 'flower vase', 'bed sheets']

>>>

Lists are enclosed in square brackets and as in case of Strings, we can make use of index or position to know which element is at which index.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.